<template>
  <el-dropdown trigger="click" @command="handleSetSize">
    <div class="size-select">
      <el-icon :size="18">
        <Operation />
      </el-icon>
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item 
          v-for="item in sizeOptions"
          :key="item.value"
          :disabled="size === item.value"
          :command="item.value"
        >
          {{ item.label }}
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { ElMessage } from 'element-plus'
import { Operation } from '@element-plus/icons-vue'
import { useAppStore } from '@/stores/app'

const appStore = useAppStore()

// 尺寸选项
const sizeOptions = [
  { label: '默认', value: 'default' },
  { label: '大', value: 'large' },
  { label: '小', value: 'small' }
]

// 当前尺寸
const size = computed(() => appStore.size)

// 处理尺寸设置
const handleSetSize = (size: string) => {
  appStore.setSize(size as 'default' | 'large' | 'small')
  ElMessage.success(`切换尺寸成功: ${sizeOptions.find(item => item.value === size)?.label}`)
}
</script>

<style scoped></style>
